<?php

namespace app\talk;

use app\server\WechartServer;
use think\Env;
class notify
{
    public function __construct()
    {

    }
    public function wechart()
    {
        $option=array();
        $option['code']=input('code');
        $option['state']=input('state');
        $server=new WechartServer();
        $result=$server->getToken($option);
        $result=json_decode($result);
        cookie('wx_access_token',$result['access_token']);
        $openResult=$server->getUserInfo($result);
        $openResult=json_decode($openResult);
        cookie($option['state'],$openResult);
        $host=Env::get("web.hostname");
        header("location:".$host.cookie('back_url'));
    }
}